#include <stdio.h>
#include <stdlib.h>

#include "LinkQueue.h"


struct LinkQueue
{
    DLlist list;
};

LQueue *InitLQueue()
{
    LQueue *q = (LQueue*)malloc(sizeof(LQueue));
    if(q == NULL)
        return NULL;
    InitDLlist(&q->list);
    return q;
}

void QPush(LQueue *q, ElementType element)
{
    //尾插
    InsertDLlistTail(&q->list,element);
}

void QPop(LQueue *q)
{
    //头删
    //出队列不删数据域内容
    RemoveByIndex(&q->list,0,NULL);
}

bool IsQueueEmpty(LQueue *q)
{
    return q->list.len == 0;
}

ElementType *GetQFront(LQueue *q)
{
    //返回队头元素
    return FindByIndex(&q->list,0);
}

int GetQueueLen(LQueue *q)
{
    return q->list.len;
}

void TravelLQueue(LQueue *q,void(*funcPtr)(ElementType))
{
    TravelDLlist(&q->list,funcPtr);
}

void ClearLQueue(LQueue *q, void (*clearPtr)(ElementType))
{
    ClearDLlist(&q->list,clearPtr);
}
